package com.borderbears.backend.gui.dockables;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import com.borderbears.backend.actions.AddConnectionAction;
import com.borderbears.backend.actions.RemoveConnectionAction;
import com.borderbears.backend.connection.ConnectionManager;
import com.borderbears.backend.util.Config;
import com.vlsolutions.swing.docking.DockKey;
import com.vlsolutions.swing.docking.Dockable;

public class ConnectionsPanel extends JPanel implements Dockable {
	private final DockKey dockKey;

	private final Config conf = Config.getConfig();

	public ConnectionsPanel(final DockKey key) {
		dockKey = key;
		setLayout(new BorderLayout());

		final JPanel toolPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));


		final JButton btAdd = new JButton(new AddConnectionAction("Add"));
		toolPanel.add(btAdd);
		final JButton btRemove = new JButton(new RemoveConnectionAction("Remove"));
		toolPanel.add(btRemove);
		add(toolPanel, BorderLayout.NORTH);


		final JList list = new JList(ConnectionManager.getInstance().getListModel());
		final JScrollPane spList = new JScrollPane(list);
		add(spList);

	}

	public Component getComponent() {
		return this;
	}

	public DockKey getDockKey() {
		return dockKey;
	}

}
